package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.CarImageDao;
import com.x.erp.manage.CarImageManage;
import com.x.erp.model.CarImage;
import com.x.erp.rpc.CarImageRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 车辆图片服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.CarImageRpcService", timeout = 60000)
public class CarImageService extends BaseService implements CarImageRpcService {

	@Autowired
	private CarImageDao carImageDao;//车辆图片服务DAO
	
	@Autowired
	private CarImageManage carImageManage;//车辆图片服务Manage

	/**
	 * 查询车辆图片列表
	 * @param carImage
	 * @return
	 */
	@Override
	public List<CarImage> selectCarImageList(CarImage carImage, Integer imageViewId){
		try {
			return carImageDao.selectCarImageList(carImage, imageViewId);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询单张车辆图片
	 * @param carImage
	 * @return
	 */
	@Override
	public CarImage selectCarImage(CarImage carImage) {
		try {
			return carImageDao.selectCarImage(carImage);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 删除图片信息
	 * @param carImage
	 * @return
	 */
	@Override
	public int deleteCarImage(CarImage carImage) {
		try {
			return carImageManage.deleteCarImage(carImage);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
